Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
11 lines (8 loc) · 569 Bytes

3.3.5 - Coroutine/Client->peek.md

File metadata and controls

11 lines (8 loc) · 569 Bytes

Coroutine\Client->peek

窥视数据。peek方法直接操作socket,因此不会引起协程调度。

function Coroutine\Client->peek(int $length = 65535) : string;
  • peek方法仅用于窥视内核socket缓存区中的数据,不进行偏移。使用peek之后,再调用recv仍然可以读取到这部分数据
  • peek方法是非阻塞的,它会立即返回。当socket缓存区中有数据时,会返回数据内容。缓存区为空时返回false,并设置$client->errCode
  • 连接已被关闭peek会返回空字符串